/*
 * $Id: sem.h,v 1.3 2006-06-03 15:56:31 bacon Exp $
 */

#ifndef _XP_BAS_SEM_H_
#define _XP_BAS_SEM_H_

#include <xp/types.h>
#include <xp/macros.h>

#if defined(_WIN32)
#include <windows.h>
#else
#include <semaphore.h>
#endif

#if defined(_WIN32)
	typedef HANDLE xp_semhnd_t;
#else
	typedef sem_t xp_semhnd_t;
#endif
	
typedef struct xp_sem_t xp_sem_t;

struct xp_sem_t
{
	xp_semhnd_t hnd;
	xp_bool_t __dynamic;
};

#ifdef __cplusplus
extern "C" {
#endif

xp_sem_t* xp_sem_open (xp_sem_t* sem, unsigned int init);
int xp_sem_close (xp_sem_t* sem);

int xp_sem_acquire (xp_sem_t* sem);
int xp_sem_release (xp_sem_t* sem);

#endif

